<div class="rightcontent rc-bg-grey">
    <div class="rc-pagepadding">


        <div class=" rc-pannel ">
            <div class=" rc-pannel-header">
                <div class="rc-flex layui-form toolbar rc-flex-justify-between">
                    <div class=" rc-flex rc-flex-vertical-center ">

                    </div>
                    <div>
                        <a href="/app/cms/admin/Tag/add" class="layui-btn layui-btn-primary layui-btn-sm"><i class="iconfont">&#xe60e;</i> 添加标签</a>

                    </div>
                </div>


            </div>


            <div class="rc-pannel-body layui-form rc-pagepadding">

                <table class="layui-table">
                    <colgroup>
                        <col style="width:60px;">
                        <col>

                        <col style="width: 240px;">

                    </colgroup>
                    <thead>
                        <tr>
                            <th>编号</th>
                            <th>标签名称</th>
                            <th></th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php
                        foreach ($tags as $tag) {
                        ?>
                            <tr>
                                <td><?php echo $tag->id ?></td>
                                <td><?php echo $tag->tag ?></td>
                                <td>

                                    <div class="rc-opbar">
                                        <a class="info" href="/app/cms/admin/Tag/edit?id=<?php echo $tag->id ?>"><i class="iconfont">&#xe606;</i> 编辑</a>
                                        <a class="error delete" tagid="<?php echo $tag->id ?>"><i class="iconfont">&#xe607;</i> 删除 </a>
                                    </div>

                                </td>
                            </tr>
                        <?php
                        }
                        ?>
                    </tbody>
                </table>



            </div>

            <div class="rc-pannel-footer ">
                <div class="rc-padding-right-default rc-padding-left-default" style="text-align: center;">
                    <?php echo paginator($tags->total(), 20); ?>
                </div>

            </div>
        </div>
    </div>
</div>
<script>
    layui.use(function() {

        var layer = layui.layer;
        $('.delete').click(function() {
            var tagid = $(this).attr('tagid');
            layer.confirm('确定要删除么？', {
                btn: ['确定', '关闭'] //按钮
            }, function() {
                $.ajax({
                    url: '/app/cms/admin/Tag/delete?id=' + tagid, //请求路径
                    type: "POST", //请求方式
                    success: function(data) {
                        if (data.code != 0) {
                            toastr_error(data.message);
                        } else {
                            window.location.reload();
                        }
                    },
                    error: function() {},
                    complete: function() {
                        layer.closeAll();
                    }
                });
            }, function() {


            });
        });


    });
</script>